# 练习文件读取

f = open("D:/PycharmProjects/example/a.txt", "r", encoding="UTF-8")
for line in f:
    print(f"每一行的数据是：" + line)

print(type(f))

f.close()

f.write("hello world1")
f.write("hello world2")
f.write("hello world3")

f.flush()


with open("D:/PycharmProjects/example/a.txt", "w", encoding="UTF-8") as f:
    for line in f:
        print(f"每一行的数据是：" + line)

    print(type(f))
